package com.talos.ums.dal.mysql.role;

import com.talos.framework.common.pojo.PageResult;
import com.talos.framework.mybatis.core.mapper.BaseMapperX;
import com.talos.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.talos.ums.controller.admin.role.vo.UmsRolePageReqVO;
import com.talos.ums.dal.dataobject.role.UmsRoleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 角色表 Mapper
 *
 * @author ${table.author}
 */
@Mapper
public interface UmsRoleMapper extends BaseMapperX<UmsRoleDO> {

    default PageResult<UmsRoleDO> selectPage(UmsRolePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UmsRoleDO>()
                .eqIfPresent(UmsRoleDO::getRoleCode, reqVO.getRoleCode())
                .likeIfPresent(UmsRoleDO::getRoleName, reqVO.getRoleName())
                .eqIfPresent(UmsRoleDO::getRemark, reqVO.getRemark())
                .eqIfPresent(UmsRoleDO::getRoleType, reqVO.getRoleType())
                .eqIfPresent(UmsRoleDO::getWarehouseCode, reqVO.getWarehouseCode())
                .eqIfPresent(UmsRoleDO::getCreatorId, reqVO.getCreatorId())
                .betweenIfPresent(UmsRoleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(UmsRoleDO::getCreatorCode, reqVO.getCreatorCode())
                .likeIfPresent(UmsRoleDO::getCreatorName, reqVO.getCreatorName())
                .eqIfPresent(UmsRoleDO::getModifierId, reqVO.getModifierId())
                .betweenIfPresent(UmsRoleDO::getModifyTime, reqVO.getModifyTime())
                .eqIfPresent(UmsRoleDO::getModifierCode, reqVO.getModifierCode())
                .likeIfPresent(UmsRoleDO::getModifierName, reqVO.getModifierName())
                .eqIfPresent(UmsRoleDO::getStatus, reqVO.getStatus())
                .eqIfPresent(UmsRoleDO::getCompanyCode, reqVO.getCompanyCode())
                .eqIfPresent(UmsRoleDO::getTenantId, reqVO.getTenantId())
                .orderByDesc(UmsRoleDO::getId));
    }

}
